
package com.huizhan.web;

import org.springframework.core.MethodParameter;
import org.springframework.web.context.request.NativeWebRequest;
import org.springframework.web.method.support.HandlerMethodReturnValueHandler;
import org.springframework.web.method.support.ModelAndViewContainer;
//import com.huizhan.web.model.*;

public class ResponseBodyWrapHandler implements HandlerMethodReturnValueHandler{
	
	private final HandlerMethodReturnValueHandler delegate;

	public ResponseBodyWrapHandler(HandlerMethodReturnValueHandler delegate){
		this.delegate = delegate;
	}

	@Override
	public boolean supportsReturnType(MethodParameter returnType) {
		return delegate.supportsReturnType(returnType);
	}

	@Override
	public void handleReturnValue(Object returnValue, MethodParameter returnType, ModelAndViewContainer mavContainer,NativeWebRequest webRequest) throws Exception {
		/*if(returnValue instanceof ApiResult){
            delegate.handleReturnValue(returnValue, returnType, mavContainer, webRequest);
		}else{
			ApiResult<Object> rtnMsg = new ApiResult<Object>();
            delegate.handleReturnValue(rtnMsg, returnType, mavContainer, webRequest);
        }*/
        
        delegate.handleReturnValue(returnValue, returnType, mavContainer, webRequest);
	}
}
